home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / subs.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  8KB  |  246 lines

  1. /***************************************************************************
  2.  
  3. Subs Driver
  4.  
  5. If you have any questions about how this driver works, don't hesitate to
  6. ask.  - Mike Balfour (mab22@po.cwru.edu)
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12. /* vidhrdw/subs.c */
  13. extern void subs_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  14. WRITE_HANDLER( subs_invert1_w );
  15. WRITE_HANDLER( subs_invert2_w );
  16.  
  17. /* machine/subs.c */
  18. extern void subs_init_machine(void);
  19. extern int subs_interrupt(void);
  20. WRITE_HANDLER( subs_steer_reset_w );
  21. READ_HANDLER( subs_control_r );
  22. READ_HANDLER( subs_coin_r );
  23. READ_HANDLER( subs_options_r );
  24. WRITE_HANDLER( subs_lamp1_w );
  25. WRITE_HANDLER( subs_lamp2_w );
  26. WRITE_HANDLER( subs_noise_reset_w );
  27. WRITE_HANDLER( subs_sonar2_w );
  28. WRITE_HANDLER( subs_sonar1_w );
  29. WRITE_HANDLER( subs_crash_w );
  30. WRITE_HANDLER( subs_explode_w );
  31.  
  32. static struct MemoryReadAddress readmem[] =
  33. {
  34.     { 0x0000, 0x0007, subs_control_r },
  35.     { 0x0020, 0x0027, subs_coin_r },
  36.     { 0x0060, 0x0063, subs_options_r },
  37.     { 0x0000, 0x01ff, MRA_RAM },
  38.     { 0x0800, 0x0bff, MRA_RAM },
  39.     { 0x2000, 0x3fff, MRA_ROM },
  40.     { 0xf000, 0xffff, MRA_ROM }, /* A14/A15 unused, so mirror ROM */
  41.     { -1 }    /* end of table */
  42. };
  43.  
  44. static struct MemoryWriteAddress writemem[] =
  45. {
  46.     { 0x0000, 0x0000, subs_noise_reset_w },
  47.     { 0x0020, 0x0020, subs_steer_reset_w },
  48. //    { 0x0040, 0x0040, subs_timer_reset_w },
  49.     { 0x0060, 0x0061, subs_lamp1_w },
  50.     { 0x0062, 0x0063, subs_lamp2_w },
  51.     { 0x0064, 0x0065, subs_sonar2_w },
  52.     { 0x0066, 0x0067, subs_sonar1_w },
  53.     { 0x0068, 0x0069, subs_crash_w },
  54.     { 0x006a, 0x006b, subs_explode_w },
  55.     { 0x006c, 0x006d, subs_invert1_w },
  56.     { 0x006e, 0x006f, subs_invert2_w },
  57.     { 0x0090, 0x009f, spriteram_w, &spriteram },
  58.     { 0x0000, 0x07ff, MWA_RAM },
  59.     { 0x0800, 0x0bff, videoram_w, &videoram, &videoram_size },
  60.     { 0x2000, 0x3fff, MWA_ROM },
  61.     { -1 }    /* end of table */
  62. };
  63.  
  64. INPUT_PORTS_START( subs )
  65.     PORT_START /* OPTIONS */
  66.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )
  67.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  68.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  69.     PORT_DIPNAME( 0x02, 0x00, "Credit/Time" )
  70.     PORT_DIPSETTING(    0x00, "Each Coin Buys Time" )
  71.     PORT_DIPSETTING(    0x02, "Fixed Time" )
  72.     PORT_DIPNAME( 0x0c, 0x00, "Game Language" )
  73.     PORT_DIPSETTING(    0x00, "English" )
  74.     PORT_DIPSETTING(    0x04, "Spanish" )
  75.     PORT_DIPSETTING(    0x08, "French" )
  76.     PORT_DIPSETTING(    0x0c, "German" )
  77.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Free_Play ) )
  78.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  79.     PORT_DIPSETTING(    0x10, DEF_STR( On ) )
  80.     PORT_DIPNAME( 0xe0, 0x40, "Game Length" )
  81.     PORT_DIPSETTING(    0x00, "0:30 Minutes" )
  82.     PORT_DIPSETTING(    0x20, "1:00 Minutes" )
  83.     PORT_DIPSETTING(    0x40, "1:30 Minutes" )
  84.     PORT_DIPSETTING(    0x60, "2:00 Minutes" )
  85.     PORT_DIPSETTING(    0x80, "2:30 Minutes" )
  86.     PORT_DIPSETTING(    0xa0, "3:00 Minutes" )
  87.     PORT_DIPSETTING(    0xc0, "3:30 Minutes" )
  88.     PORT_DIPSETTING(    0xe0, "4:00 Minutes" )
  89.  
  90. PORT_START /* IN1 */
  91.     PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Diag Step */
  92.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Diag Hold */
  93.     PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_TILT )    /* Slam */
  94.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )  /* Spare */
  95.     PORT_BIT ( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Filled in with steering information */
  96.  
  97.     PORT_START /* IN2 */
  98.     PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
  99.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_START1 )
  100.     PORT_BIT ( 0x04, IP_ACTIVE_HIGH, IPT_COIN2 )
  101.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_START2 )
  102.     PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_VBLANK )
  103.     PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
  104.     PORT_BITX( 0x40, IP_ACTIVE_LOW, IPT_SERVICE | IPF_TOGGLE, "Self Test", KEYCODE_F2, IP_JOY_NONE )
  105.     PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 )
  106.  
  107. PORT_START      /* IN3 */
  108.     PORT_ANALOG( 0xff, 0x00, IPT_DIAL, 100, 10, 0, 0 )
  109.  
  110. PORT_START      /* IN4 */
  111.     PORT_ANALOG( 0xff, 0x00, IPT_DIAL | IPF_PLAYER2, 100, 10, 0, 0 )
  112.  
  113. INPUT_PORTS_END
  114.  
  115.  
  116. static unsigned char palette[] =
  117. {
  118.     0x00,0x00,0x00, /* BLACK - modified on video invert */
  119.     0xff,0xff,0xff, /* WHITE - modified on video invert */
  120.     0x00,0x00,0x00, /* BLACK - modified on video invert */
  121.     0xff,0xff,0xff, /* WHITE - modified on video invert*/
  122. };
  123. static unsigned short colortable[] =
  124. {
  125.     0x00, 0x01,        /* Right screen */
  126.     0x02, 0x03        /* Left screen */
  127. };
  128. static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
  129. {
  130.     memcpy(game_palette,palette,sizeof(palette));
  131.     memcpy(game_colortable,colortable,sizeof(colortable));
  132. }
  133.  
  134.  
  135. static struct GfxLayout playfield_layout =
  136. {
  137.     8,8,    /* 8*8 characters */
  138.     256,    /* 256 characters */
  139.     1,    /* 1 bits per pixel */
  140.     { 0 }, /* No info needed for bit offsets */
  141.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  142.     { 0, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  143.     8*8 /* every char takes 8 consecutive bytes */
  144. };
  145.  
  146. static struct GfxLayout motion_layout =
  147. {
  148.     16,16,    /* 16*16 characters */
  149.     64,        /* 64 characters */
  150.     1,    /* 1 bits per pixel */
  151.     { 0 }, /* No info needed for bit offsets */
  152.     { 3 + 0x400*8, 2 + 0x400*8, 1 + 0x400*8, 0 + 0x400*8,
  153.       7 + 0x400*8, 6 + 0x400*8, 5 + 0x400*8, 4 + 0x400*8,
  154.       3, 2, 1, 0, 7, 6, 5, 4 },
  155.     { 0, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  156.       8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  157.     16*8 /* every char takes 16 consecutive bytes */
  158. };
  159.  
  160. static struct GfxDecodeInfo gfxdecodeinfo[] =
  161. {
  162.     { REGION_GFX1, 0, &playfield_layout, 0, 2 },     /* playfield graphics */
  163.     { REGION_GFX2, 0, &motion_layout,    0, 2 },     /* motion graphics */
  164.     { -1 } /* end of array */
  165. };
  166.  
  167. static struct MachineDriver machine_driver_subs =
  168. {
  169.     /* basic machine hardware */
  170.     {
  171.         {
  172.             CPU_M6502,
  173.             12096000/16,        /* clock input is the "4H" signal */
  174.             readmem,writemem,0,0,
  175.             subs_interrupt,4    /* NMI interrupt on the 32V signal if not in self-TEST */
  176.         }
  177.     },
  178.     57, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  179.     1,    /* single CPU, no need for interleaving */
  180.     subs_init_machine,
  181.  
  182.     /* video hardware */
  183.     64*8, 32*8, { 0*8, 64*8-1, 0*8, 32*8-1 },
  184.     gfxdecodeinfo,
  185.     sizeof(palette) / sizeof(palette[0]) / 3, sizeof(colortable) / sizeof(colortable[0]),
  186.     init_palette,
  187.  
  188.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_DUAL_MONITOR,
  189.     0,
  190.     generic_vh_start,
  191.     generic_vh_stop,
  192.     subs_vh_screenrefresh,
  193.  
  194.     /* sound hardware */
  195.     0,0,0,0,
  196. };
  197.  
  198.  
  199. /***************************************************************************
  200.  
  201.   Game ROMs
  202.  
  203. ***************************************************************************/
  204.  
  205. ROM_START( subs )
  206.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
  207.     ROM_LOAD( "34190.p1",     0x2800, 0x0800, 0xa88aef21 )
  208.     ROM_LOAD( "34191.p2",     0x3000, 0x0800, 0x2c652e72 )
  209.     ROM_LOAD( "34192.n2",     0x3800, 0x0800, 0x3ce63d33 )
  210.     ROM_RELOAD(               0xf800, 0x0800 )
  211.     /* Note: These are being loaded into a bogus location, */
  212.     /*         They are nibble wide rom images which will be */
  213.     /*         merged and loaded into the proper place by    */
  214.     /*         subs_rom_init()                               */
  215.     ROM_LOAD( "34196.e2",     0x8000, 0x0100, 0x7c7a04c3 )    /* ROM 0 D4-D7 */
  216.     ROM_LOAD( "34194.e1",     0x9000, 0x0100, 0x6b1c4acc )    /* ROM 0 D0-D3 */
  217.  
  218.     ROM_REGION( 0x0800, REGION_GFX1 | REGIONFLAG_DISPOSE )
  219.     ROM_LOAD( "34211.m4",     0x0000, 0x0800, 0xfa8d4409 )    /* Playfield */
  220.  
  221.     ROM_REGION( 0x0800, REGION_GFX2 | REGIONFLAG_DISPOSE )
  222.     ROM_LOAD( "34216.d7",     0x0000, 0x0200, 0x941d28b4 )    /* Motion */
  223.     ROM_LOAD( "34218.e7",     0x0200, 0x0200, 0xf4f4d874 )    /* Motion */
  224.     ROM_LOAD( "34217.d8",     0x0400, 0x0200, 0xa7a60da3 )    /* Motion */
  225.     ROM_LOAD( "34219.e8",     0x0600, 0x0200, 0x99a5a49b )    /* Motion */
  226.  
  227. ROM_END
  228.  
  229.  
  230. static void init_subs(void)
  231. {
  232.     unsigned char *rom = memory_region(REGION_CPU1);
  233.     int i;
  234.  
  235.     /* Merge nibble-wide roms together,
  236.        and load them into 0x2000-0x20ff */
  237.  
  238.     for(i=0;i<0x100;i++)
  239.     {
  240.         rom[0x2000+i] = (rom[0x8000+i]<<4)+rom[0x9000+i];
  241.     }
  242. }
  243.  
  244.  
  245. GAMEX( 1977, subs, 0, subs, subs, subs, ROT0, "Atari", "Subs", GAME_NO_SOUND )
  246.